#include"ThreadPool.hpp"
#include<memory>

int main()
{
    //构造函数的时候，就把线程创建完毕并放到线程池中
    std::unique_ptr<ThreadPool<Task> > tpool(new ThreadPool<Task>()); 
    tpool->run(); //执行run函数-->调用线程池所有线程的start方法

    while(1)
    {
        //先给个任务给到线程池中
        int x, y;
        cout << "请输入数据x：\n";
        cin >> x;
        cout << "请输入数据y：\n";
        cin >> y;
        char oper;
        cout << "在+-*/%中选择要计算的运算符号: \n";
        cin >> oper;
        Task t(x, y, oper, mymath);
        cout << "成功创建任务：" << t.toTaskString() << "\n";
        cout << "确定要提交吗 [y/n]\n";
        char confirm;
        cin >> confirm;
        if(confirm == 'y')
        {
            tpool->Push(t);
        }
        sleep(1);
    }

    return 0;
}
